package com.hxx.day8a.service.impl;

import com.hxx.day5example.domain.Emp;
import com.hxx.day8a.common.HxxUtils;
import com.hxx.day8a.mapper.BaseMapper;
import com.hxx.day8a.mapper.iml.BaseMapperImpl;
import com.hxx.day8a.service.EmpService;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

public class EmpServiceImpl implements EmpService {

   private BaseMapper<Emp> baseMapper = new BaseMapperImpl<>();

    @Override
    public File findById(Long id) {
        return null;
    }

    @Override
    public void save(Emp emp) {
        try {
            emp.setId(HxxUtils.getKey());
            baseMapper.save(emp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void update(Emp emp) {
    }

    @Override
    public void delete(Long id) {
        File file = findById(id);
        if (file!=null) {
            file.delete();
            System.out.println("删除成功");
        }
    }

    @Override
    public List<Emp> findAll() {
        try {
            return baseMapper.findAll(Emp.class);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
























